<template>
	<div>
		<div class="downloadmain">
			<img src="../assets/maskback.png" class="downloadimg">
			<div class="downloadcon">
				<div class="compylogo"><img src="../assets/compylogo.png"></div>
				<div class="downmodule">
					<div class="samebutton" v-show="iphonedown" @click="iosbut"><i class="samelogo iphoneimg"></i>iphone用户下载</div>
					<!--<div class="samebutton" v-show="androidown" @click="androidbut"><i class="samelogo androidimg"></i>Android用户下载</div>-->
					<div class="samebutton" v-show="androidown" v-if='yyb == "0"' @click="myapp"><i class="samelogo myappimg"></i>应用宝平台下载</div>
					
					<div class="samebutton" v-show="androidown" v-if='yhj == "0"' @click="yh"><i class="samelogo yhimg"></i>友惠家平台下载</div>
					
					<div class="samebutton" v-show="androidown" v-if='three == "0"' @click="threeon"><i class="samelogo threeimg"></i>360平台下载</div>
					
					<div class="samebutton" v-show="androidown" v-if='huawei == "0"' @click="huaweion"><i class="samelogo huaweiimg"></i>华为平台下载</div>
				</div>
			</div>
		</div>
		<div class="maskcon" v-show="hidemask"><img src="../assets/wxmask.png"></div>

	</div>
</template>

<script>
	import { BaseUrl } from '../Baseurl/common.js';
	import { Toast } from 'mint-ui';
	export default {
		data() {
			return {
				hidemask: false,
				iphonedown: true,
				androidown: true,
				yhj:1,
				yyb:1,
				three:1,
				huawei:1,
			}
		},
		created() {
			//判断下载地址
			var url = BaseUrl + 'project/download' ;
			this.$http.post(url).then(res=>{
				var aa =[];
				if(res.data.code == '10000'){
					var downloadlsit = res.data.data;
					var aa = downloadlsit.split(',')
					
					
					if(aa.indexOf('yhj') != -1){
						this.yhj = 0
					};
					if(aa.indexOf('yyb') != -1){
						this.yyb = 0
					};
					if(aa.indexOf('360') != -1){
						this.three = 0
					};
					if(aa.indexOf('huawei') != -1){
						this.huawei = 0
					};
				}
			}).catch(error=>{
				Toast({
					message: "网络异常",
					position: 'middle',
					duration: 3000
				})
			})
			
			var browser = {
				versions: function() {
					var u = navigator.userAgent,
						app = navigator.appVersion;
					return { //移动终端浏览器版本信息
						trident: u.indexOf('Trident') > -1, //IE内核
						presto: u.indexOf('Presto') > -1, //opera内核
						webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
						gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
						mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
						ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
						android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
						iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
						iPad: u.indexOf('iPad') > -1, //是否iPad
						webApp: u.indexOf('Safari') == -1 //是否web应该程序，没有头部与底部
					};
				}(),
				language: (navigator.browserLanguage || navigator.language).toLowerCase()
			}
			if(browser.versions.mobile) { //判断是否是移动设备打开。browser代码在下面
				var ua = navigator.userAgent.toLowerCase(); //获取判断用的对象
				if(ua.match(/MicroMessenger/i) == "micromessenger") {
//					this.hidemask = true;
//					if(browser.versions.ios){
//						this.hidemask = false;
//					}else{.
	
//						this.hidemask = false;
//					}
				}
				if(browser.versions.ios) {
					//是否在IOS浏览器打开
					this.androidown = false;
				}
				if(browser.versions.android) {
					//是否在安卓浏览器打开
					this.iphonedown = false;
//					this.hidemask = true;
				}
			}
			//判断下载地址
//			var url = BaseUrl + '';
		},
		methods: {
			//安卓下载
			androidbut: function() {
//				window.location.href ="http://www.uhuijia.com.cn/mall.apk"
//				window.location.href = "http://a.app.qq.com/o/simple.jsp?pkgname=com.huifaapp.mall&from=singlemessage"
			},
			//苹果下载
			iosbut:function(){
				window.location.href = "https://itunes.apple.com/cn/app/%E5%8F%8B%E6%83%A0%E5%AE%B6/id1278845049?mt=8"
			},
			//360下载地址
			threeon:function(){
				window.location.href = 'http://zhushou.360.cn/detail/index/soft_id/3895829?recrefer=SE_D_%E5%8F%8B%E6%83%A0%E5%AE%B6VIP'
			},
			//华为下载地址
			huaweion:function(){
				window.location.href = 'http://app.hicloud.com/app/C100138197'
			},
			//应用宝下载
			myapp:function(){
				window.location.href = 'http://sj.qq.com/myapp/detail.htm?apkName=com.huifaapp.mall'
			},
			//友惠家下载
			yh:function(){
				var ua = navigator.userAgent.toLowerCase();
					var isWeixin = ua.indexOf('micromessenger') != -1;
					if (isWeixin) {
						this.hidemask = true;
					    return true;
					}else{
						this.hidemask = false;
						window.location.href = 'http://www.uhuijia.com.cn/mall.apk';
					    return false;
				}			
			}
		}
	}
</script>

<style scoped="scoped">
	/*****蒙版*****/
	
	.maskcon {
		width: 100%;
		height: 100%;
		top: 0rem;
		left: 0rem;
		position: fixed;
	}
	
	.maskcon>img {
		width: 100%;
		height: 100%;
	}
	
	.downloadmain {
		width: 100%;
		height: 100%;
		padding-bottom: 0.4rem;
		background-color: #f4325c;
	}
	
	.downloadimg {
		width: 100%;
		height: 100%;
		z-index: 0;
		overflow: hidden;
	}
	
	.downloadcon {
		position: absolute;
		top: 0rem;
		width: 100%;
		height: 100%;
	}
	
	.compylogo {
		width: 1.66rem;
		height: 1.66rem;
		margin: 0 auto;
		margin-top: 2.6rem;
	}
	
	.compylogo>img {
		width: 100%;
		height: 100%;
	}
	
	.downmodule {
		width: 73%;
		margin: 0 auto;
		margin-top: 2rem;
	}
	
	.samebutton {
		width: 100%;
		height: 0.88rem;
		background-color: #FFFFFF;
		border-radius: 0.08rem;
		line-height: 0.88rem;
		color: #FF2040;
		font-size: 0.3rem;
		margin-bottom: 0.4rem;
	}
	.samebutton:last-child{
		margin-bottom: 0;
	}
	/*.samebutton:nth-child(2) {
		margin-top: 0.6rem;
		display: block!important;
	}*/
	
	.samelogo {
		width: 0.42rem;
		height: 0.42rem;
		display: inline-block;
		margin-left: 1.34rem;
		position: relative;
		top: 0.1rem;
		margin-right: 0.1rem;
	}
	.iphoneimg {
		background: url(../assets/iphone.png);
		background-size: 100% 100%;
		margin-right: 0.63rem;
	}
	
	.androidimg {
		background: url(../assets/android.png);
		background-size: 100% 100%;
		margin-right: 0.63rem;
	}
	.myappimg{
		background: url(../assets/myapp.png);
		background-size: 100% 100%;
		margin-right: 0.63rem;
	}
	.yhimg{
		background: url(../assets/yhdownload.png);
		background-size: 100% 100%;
		margin-right: 0.63rem;
	}
	.threeimg{
		background: url(../assets/360.png);
		background-size: 100% 100%;
		margin-right: 0.63rem;
	}
	.huaweiimg{
		background: url(../assets/huawei.png);
		background-size: 100% 100%;
		margin-right: 0.63rem;
	}
</style>